home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / SK (Sockects) 1.4.1 r2 / SK v1.4.1 r2.sit / SK 1.4.1 r2 / CU / CU_Debug.c next >
Text File  |  1994-06-14  |  5KB  |  195 lines

  1.  
  2. /***************************************************************************
  3. * (c) Copyright 1993, Decision Systems Group.  All rights reserved.
  4. * THIS IS A DEVELOPMENT VERSION: NOT FOR USE OR DISTRIBUTION OUTSIDE 
  5. * OF THE DECISION SYSTEMS GROUP
  6. * This source code is owned by the Decision Systems Group.  Copying or
  7. * distributing any part of this file, electronically or otherwise,
  8. * either in its original or derivative form, or altering or removing
  9. * this copyright notice is in violation of federal and international
  10. * copyright laws.
  11. * ==========================================================================
  12. * FILE: CU_Debug.c
  13. * AUTHOR: 
  14. *
  15. * Stephan R.A. Deibel
  16. * YongJoon Lee
  17. * CREATION DATE: 
  18. * 8/1/93
  19. *
  20. * VERSION: 
  21. * 6/13/94
  22. *
  23. * DESCRIPTION: 
  24. * Basic debugging utilities for cross-platform development that replace
  25. * and augments some of the standard C "assert" code with generally
  26. * safer alternatives.
  27. *
  28. * For usage instructions, read the embedded comments in the header file.
  29. * MODIFICATIONS: 
  30. * --------------------------------------------------------------------------
  31. * Date     Name      Description of modification
  32. * --------------------------------------------------------------------------
  33. * 3/11/94  Stephan   Added header comments and fixed some formatting problems
  34. *                    in the Mac implementation's output.
  35. * 4/4/94   YJLee     Fixed the printf output to shorts, because the Mac
  36. *                    debugger prints out garbage long values.
  37. *
  38. * 4/5/94   YJLee     Changed printf output to short ints for line nums to 
  39. *                    fix Mac problem.
  40. *
  41. * 3/15/94  Stephan   Fixed text for UNFINISHED call -- was incorrect.
  42. *
  43. * 3/12/94  Stephan   Fixed formatting of outputted messages for Mac.
  44. *
  45. * 6/13/94  Stephan   Cosmetic / commenting
  46. */
  47.  
  48. #include "CU_Debug.h"
  49. #include <stdlib.h>
  50. #include <stdio.h>
  51.  
  52. #ifdef THINK_C
  53. #include <pascal.h>
  54. #endif
  55.  
  56. #ifdef __GNUC__
  57. #include <signal.h>
  58. #endif
  59.  
  60.  
  61. /**************************************************************************/
  62. /* GLOBALS */
  63.  
  64. #ifdef THINK_C
  65. static char gDB_DebugStr[256];
  66. #endif
  67.  
  68.  
  69. /****************************************************************************
  70. * FUNCTION:
  71. *
  72. * _DB_Assert
  73. *
  74. * DESCRIPTION:
  75. *
  76. * Enter resident debugger and print an message indicating that an ASSERT
  77. * macro has encountered an invalid condition.  The file and line number
  78. * of the ASSERT macro are given.
  79. *
  80. * PARAMETERS:
  81. *
  82. * char *          -- The file name in which the error occurred
  83. * unsigned int    -- The line number on which the error occurred.
  84. *
  85. */
  86.  
  87. void 
  88. _DB_Assert(char *file_name, unsigned int line_num)
  89. {
  90. #ifdef THINK_C
  91.   sprintf(gDB_DebugStr, "Assertion failed:  %s, line %hu", file_name,
  92.           line_num); 
  93.   DebugStr (CtoPstr(gDB_DebugStr));
  94.   ExitToShell();
  95. #endif /* THINK_C*/
  96.  
  97. #ifdef __GNUC__
  98.   /* Print error message to standard error */
  99.   fprintf(stderr, "\nAssertion failed:  %s, line %hu\n", file_name,
  100.           line_num); 
  101.  
  102.   /* Send an interrupt signal to the current proccess */
  103.   kill(getpid(), SIGINT);
  104. #endif /* __GNUC__ */
  105. }
  106.  
  107.  
  108. /****************************************************************************
  109. * FUNCTION:
  110. *
  111. * _DB_Unimplemented
  112. *
  113. * DESCRIPTION:
  114. *
  115. * Enter resident debugger and print an message indicating that an
  116. * UNIMPLEMENTED macro has been encountered.
  117. *
  118. * PARAMETERS:
  119. *
  120. * char *          -- The file name in which the error occurred
  121. * unsigned int    -- The line number on which the error occurred.
  122. *
  123. */
  124.  
  125. void 
  126. _DB_Unimplemented(char *file_name, unsigned int line_num)
  127. {
  128. #ifdef THINK_C
  129.   sprintf(gDB_DebugStr, "Unimplemented routine:  %s, line %hu",
  130.       file_name, line_num); 
  131.   DebugStr(CtoPstr(gDB_DebugStr));
  132.   ExitToShell();
  133. #endif /* THINK_C*/
  134.  
  135. #ifdef __GNUC__
  136.   fprintf(stderr, "\nUnimplemented routine:  %s, line %hu\n",
  137.       file_name, line_num); 
  138.  
  139.   /* send an interrupt signal to the current proccess */
  140.   kill(getpid(), SIGINT);
  141. #endif /* __GNUC__ */
  142. }
  143.  
  144.  
  145. /****************************************************************************
  146. * FUNCTION:
  147. *
  148. * _DB_Unfinished
  149. *
  150. * DESCRIPTION:
  151. *
  152. * Similar to UNIMPLEMENTED execpt it will not crash the system.
  153. *
  154. * PARAMETERS:
  155. *
  156. * char *      -- The file name in which the error occurred
  157. * unsigned int    -- The line number on which the error occurred.
  158. *
  159. */
  160.  
  161. void 
  162. _DB_Unfinished(char *file_name, unsigned int line_num)
  163. {
  164. #ifdef THINK_C
  165.   sprintf(gDB_DebugStr, "Unfinished code in routine:  %s, line %hu\n", 
  166.       file_name, line_num);  
  167.   fprintf(stderr, "%s", gDB_DebugStr);
  168. #endif /* THINK_C*/
  169.  
  170. #ifdef __GNUC__
  171.   fprintf(stderr, "\nUnfinished code in routine:  %s, line %hu\n",
  172.       file_name, line_num); 
  173.  
  174. #endif /* __GNUC__ */
  175. }
  176.  
  177.  
  178. /* end of CU_Debug.c */
  179.